Skip to content

fix(cluster): recover sharded pubsub topology after node reconnects#3223

Open
PavelPashov wants to merge 10 commits into
redis:masterfrom
PavelPashov:fix/cluster-sharded-pubsub-topology-recovery
Open

fix(cluster): recover sharded pubsub topology after node reconnects#3223
PavelPashov wants to merge 10 commits into
redis:masterfrom
PavelPashov:fix/cluster-sharded-pubsub-topology-recovery

Conversation

@PavelPashov
Copy link
Copy Markdown
Contributor

@PavelPashov PavelPashov commented Apr 9, 2026

Description

Describe your pull request here


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

Note

Medium Risk
Adds automatic background rediscovery triggered by node reconnection events, which changes cluster slot discovery behavior and could cause extra topology refreshes or missed exclusions under reconnection storms.

Overview
Improves cluster recovery by tracking post-ready node reconnection attempts and scheduling a de-duplicated background topology refresh once a configurable delay elapses, while excluding currently reconnecting node addresses from the refresh attempt.

Introduces ClusterReconnectionTracker (with unit tests) and wires it into RedisClusterSlots lifecycle/events (reconnecting/ready/end, node removal, unsubscribe, destroy) to maintain accurate reconnecting state.

Extends RedisClusterSlots.rediscover to optionally start from known nodes (before falling back to root nodes) and adds a new cluster option topologyRefreshOnReconnectionAttemptStrategy to control the refresh delay/behavior. Updates sharded pubsub E2E tests to use shared testUtils harness and exercise multiple failure scenarios (failover/node/proxy/shard) plus unsubscribe behavior.

Reviewed by Cursor Bugbot for commit aae8c63. Bugbot is set up for automated code reviews on this repo. Configure here.

@PavelPashov PavelPashov marked this pull request as ready for review April 29, 2026 08:22
Comment thread packages/client/lib/cluster/cluster-slots.ts Outdated
@PavelPashov PavelPashov force-pushed the fix/cluster-sharded-pubsub-topology-recovery branch from 3cb7843 to 8281293 Compare April 29, 2026 10:33
Comment thread packages/client/lib/cluster/cluster-slots.spec.ts Outdated
Comment thread packages/client/lib/cluster/cluster-slots.ts
Comment thread eslint.config.mjs
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 07c5cf1. Configure here.

Comment thread packages/client/lib/cluster/cluster-slots.ts
@PavelPashov PavelPashov force-pushed the fix/cluster-sharded-pubsub-topology-recovery branch from 07c5cf1 to aae8c63 Compare May 11, 2026 09:30
Copy link
Copy Markdown
Collaborator

@nkaradzhov nkaradzhov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants